import time
import threading

result = 0

def func1(num):
    for i in range(num):
        lock.acquire()
        global result
        result += 1
        lock.release()
    print("func1", result)

def func2(num):
    for i in range(num):
        lock.acquire()
        global result
        result += 1
        lock.release()
    print("func2", result)


if __name__ == '__main__':
    # func1()
    # func2()
    print(result)
    lock = threading.Lock()
    t1 = threading.Thread(target=func1, args=(1000000,))
    t2 = threading.Thread(target=func2, kwargs={"num": 1000000})

    t1.start()
    t2.start()
    time.sleep(1)
    print("结束了")
